package com.ceres.device.dao;

import com.ceres.device.pojo.Device;
import com.ceres.device.pojo.Info;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Service
public interface InfoMapper extends Mapper<Info> {
    /**
     *  智能智能设备说明书新增功能
     */

    @Insert("insert into t_info values (#{id},#{did},#{time},#{weight},#{rangel},#{source},#{info},#{param},#{installes})")
    int infoAdd(Info info);

    /**
     *   根据智能设备说明书id查询一个集合智能设备说明书的功能
     */
    @Select("select * from t_info where did = #{infoId}")
    List<Info>select2Info(Integer infoId);

    /**
     *   根据智能设备的说明书实体修改智能设备说明书的功能
     */
    @Update("update t_info set did=#{did},time=#{time},weight=#{weight},rangel=#{rangel},source=#{source},info=#{info},param=#{param},installes=#{installes} where id=#{id}")
    int updateByInfo(Info infoEntity);

    /**
     *   根据智能设备的Id 查询单个智能设备说明书的功能
     */
    @Select("select did,time,weight,rangel,source,info,param,installes from t_info where id = #{infoId}")
    Info selectInfoOne(Integer infoId);

    /**
     *  分页查询（条件查询）
     */
    @Select("<script>select * from t_info <if test=\"queryString!=null and queryString!=''\">where id=#{queryString} or did=#{queryString}</if></script>")
    com.github.pagehelper.Page<Info> select6all(@Param("queryString") String queryString);

}

